package com.mall.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.system.entity.Role;
import com.mall.system.mapper.RoleMapper;
import com.mall.system.service.RoleService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * 角色服务实现类
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
    
    @Override
    public List<Role> selectRoleByUserId(Long userId) {
        return this.baseMapper.selectRoleByUserId(userId);
    }
    
    @Override
    public Set<String> selectRolePermissionByUserId(Long userId) {
        List<Role> roles = this.baseMapper.selectRoleByUserId(userId);
        return roles.stream()
                .map(Role::getRoleKey)
                .collect(Collectors.toSet());
    }
}